<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
	</body>
	<script>
		// date 代表指定的日期，格式：2018-09-27
		// day 传-1表始前一天，传1表始后一天
		// JS获取指定日期的前一天，后一天
		function getNextDate(date, day) {
			if(!date) date=new Date();
			var dd = new Date(date);
			dd.setDate(dd.getDate() + day);
			var y = dd.getFullYear();
			var m = dd.getMonth() + 1 < 10 ? "0" + (dd.getMonth() + 1) : dd.getMonth() + 1;
			var d = dd.getDate() < 10 ? "0" + dd.getDate() : dd.getDate();
			return y + "-" + m + "-" + d;
		}

		console.log(getNextDate("2022-03-01", -1))
		console.log(getNextDate("2022-05-31", 1))
		
		console.log(getNextDate("", -1))
		console.log(getNextDate("", 1))
	</script>
</html>
